<template>
  <div class="about">
    <h1 v-if="this.sj>=0&&sj<=5">已经凌晨了，您该休息了，超级管理员{{t_name}}</h1>
    <h1 v-else-if="this.sj>=6&&sj<=8">早上好，超级管理员{{t_name}}</h1>
    <h1 v-else-if="this.sj>=9&&sj<=11">上午好，超级管理员{{t_name}}</h1>
    <h1 v-else-if="this.sj>=12&&sj<=13">中午好，超级管理员{{t_name}}</h1>
    <h1 v-else-if="this.sj>=14&&sj<=18">下午好，超级管理员{{t_name}}</h1>
    <h1 v-else-if="this.sj>=19&&sj<=23">晚上好，超级管理员{{t_name}}</h1>
      <h3>当前系统时间为:{{ nowdatetime }}</h3>
    <el-button type="primary" @click="glbanji">管理班级</el-button>
    <el-button type="primary" @click="glkecheng">管理课程</el-button>
    <el-button type="primary" @click="gljiaoshi">管理教师</el-button>
    <el-button type="primary">管理登录信息</el-button>
  </div>
</template>

<script>
const axios = require("axios");
export default {
  name: "About",
  data() {
    return {
      t_name:'',
      nowdatetime: "",
      t_bianhao: "",
      sj:new Date().getHours(),
    };
  },
  methods: {
    glbanji(){
      this.$router.push({ name: "GLbanji" });
    },
    glkecheng(){
      this.$router.push({ name: "GLkecheng" });
    },
    gljiaoshi(){
     this.$router.push({ name: "GLteacher" });
    },
    chaxun() {
      let _this = this;
      axios
        .get("https://localhost:44391/api/zhuce/chaxunbianhao", {
          params: {
            t_bianhao: this.t_bianhao,
          },
        })
        .then(function (response) {
          console.log(response.data);
          _this.t_name = response.data.t_name;
        });
    },
    setIntervalDatetime() {
      setInterval(this.formatDatetime, 1000);
    },
    formatDatetime() {
      let datetime = new Date();
      let year = datetime.getFullYear();
      let month = datetime.getMonth() + 1;
      let date = datetime.getDate();
      let hour = datetime.getHours();
      let minute = datetime.getMinutes();
      let second = datetime.getSeconds();
      this.nowdatetime =
        year +
        "年" +
        this.formatNum(month) +
        "月" +
        this.formatNum(date) +
        "日" +
        this.formatNum(hour) +
        "时" +
        this.formatNum(minute) +
        "分" +
        this.formatNum(second) +
        "秒";
    },
    formatNum(num) {
      return num < 10 ? "0" + num : num;
    },
  },
  mounted() {
    this.t_bianhao = this.$store.state.t_bianhao;
    this.setIntervalDatetime();
    this.chaxun();
  },
};
</script>

<style scoped>
.el-button {
  width: 800px;
  height: 60px;
  margin-left: 10px;
  margin-top: 20px;
  font-size: 24px;
}
h1{
  font-size: 40px;
}
</style>